export default{
	namespaced : true,
	state:()=>(
	{
		address: JSON.parse(uni.getStorageSync('address') || '{}'),
		token : JSON.parse(uni.getStorageSync('token') || '""') ,
		userInfo: JSON.parse(uni.getStorageSync('userinfo')||'{}'),
		redirectInfo: null
	}
	),
	mutations:{
		saveTokenTostorage(state){
			uni.setStorageSync('token',JSON	.stringify(state.token))
		},
		saveUserInfoTostorage(state){
			uni.setStorageSync('userinfo',JSON.stringify(state.userInfo))
		},
		saveAddressToStorage(state){
			uni.setStorageSync('address',JSON.stringify(state.address))
		},
		updateRedirectInfo(state,redirectinfo){
			state.redirectInfo = redirectinfo
		},
		updateUserInfo(state,userinfo){
				state.userInfo = userinfo
				this.commit('user/saveUserInfoTostorage')
		},
		updateAddress(state,address){
			state.address = address
			this.commit('user/saveAddressToStorage')
		},
		updatetoken(state,token){
			state.token = token,
			this.commit('user/saveTokenTostorage')
		}
	},
	getters:{
		getAddress(state){
			if(!state.address.provinceName) {
				return ''
			}else{
				return state.address.provinceName+ state.address.cityName+state.address.countyName+state.address.detailInfo
			}
		}
	}
}